import React, { Component } from 'react'
import Item from '../Item'
import PropTypes from 'prop-types'
import './index.css'

export default class List extends Component {
	static propTypes = {
		todos:PropTypes.array.isRequired,
		checkTodo:PropTypes.func.isRequired,
		deleteTodo:PropTypes.func.isRequired
	}
	render() {
		//收到App逐层专递过来的checkTodo
		const {checkTodo,deleteTodo} = this.props
		return (
			<ul className="todo-main">
				{ 
				this.props.todos.map( 
						todoObj => (
							<Item 
								key={todoObj.id} 
								{...todoObj} 
								checkTodo={checkTodo}
								deleteTodo={deleteTodo}
							/> 
						)
					) 
				}
			</ul>
		)
	}
}
